home *** CD-ROM | disk | FTP | other *** search
/ Greenhouse Effect Detection Expriment / NASA Greenhouse Effect Detection Expriment 1992 - Disc 2.iso / software / dos / cdf22pc / src / tools / cdfinq.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-04  |  20.5 KB  |  731 lines

  1. /******************************************************************************
  2. *
  3. *  NSSDC/CDF                        CDFinquire.
  4. *
  5. *  Version 1.0, 4-Mar-92, ST Systems (STX)
  6. *
  7. *  Modification history:
  8. *
  9. *   V1.0   4-Mar-92, J Love       Original version.
  10. *
  11. ******************************************************************************/
  12.  
  13. #include "cdfdist.h"
  14. #include "cdfinq.h"
  15.  
  16. /******************************************************************************
  17. * Online instructions.
  18. ******************************************************************************/
  19.  
  20. static char *instructions[] =  {
  21. #if defined(vms)
  22. "Usage:         $ CDFINQUIRE [/DISPLAY=<mask>] [/OUTPUT=<file-path>] [/ID]",
  23. "                            <cdf-path>",
  24. #endif
  25. #if defined(unix)
  26. "Usage:         % cdfinquire [-display <mask>] [-output <file-path>] [-id]",
  27. "                            <cdf-path>",
  28. #endif
  29. #if defined(__MSDOS__)
  30. "Usage:         > cdfinquire [-display <mask>] [-output <file-path>] [-id]",
  31. "                               <cdf-path>",
  32. #endif
  33. "",
  34. "Purpose:       CDFinquire generates a report on a CDF's meta-data",
  35. "",
  36. "Parameter(s):  <cdf-path>",
  37. "                  The pathname of the CDF (do not enter an extension).",
  38. "",
  39. #if defined(vms)
  40. "Qualifier(s):  /DISPLAY=<mask>",
  41. #endif
  42. #if defined(unix) | defined(__MSDOS__)
  43. "Qualifier(s):  -display <mask>",
  44. #endif
  45. "                  The type of inquiry to be done.  The <mask> is made up of",
  46. "                  the following characters (at least one must be present).",
  47. "                    i  = info block (copyright, version, etc.).",
  48. "                    h  = header information (dimensionality, etc.).",
  49. "                    g  = global scope attribute definitions.",
  50. "                    g+ = global scope attribute definitions & entries.",
  51. "                    a  = variable scope attribute definitions.",
  52. "                    v  = variable definitions.",
  53. "                    v+ = variable definitions & variable scope attribute",
  54. "                         entries.",
  55. "                  If not specified, the default <mask> is 'ihg+av+'.",
  56. "",
  57. #if defined(vms)
  58. "               /OUTPUT=<file-path>",
  59. "                  Redirects the output to a file.  The file created will",
  60. "                  be named <file-path> (if <file-path> does not have an",
  61. "                  extension, `.INQ' is appended automatically).  If /OUTPUT",
  62. "                  is not specified, the output is displayed at the terminal.",
  63. #endif
  64. #if defined(unix) | defined(__MSDOS__)
  65. "               -output <file-path>",
  66. "                  Redirects the output to a file.  The file created will",
  67. "                  be named <file-path> (if <file-path> does not have an",
  68. "                  extension, `.inq' is appended automatically).  If /OUTPUT",
  69. "                  is not specified, the output is displayed at the terminal.",
  70. #endif
  71. "",
  72. #if defined(vms)
  73. "               /ID",
  74. #endif
  75. #if defined(unix) | defined(__MSDOS__)
  76. "               -id",
  77. #endif
  78. "                  Displays the version of the CDF library only.  All other",
  79. "                  parameters/qualifiers are ignored.",
  80. "",
  81. #if defined(vms)
  82. "Example(s):    $ CDFINQUIRE GISS_VEG",
  83. "               $ CDFINQUIRE/DISPLAY=ig+v CDF$SMPL:GISS_VEG",
  84. "               $ CDFINQUIRE/OUTPUT=GISS_VEGX GISS_VEG",
  85. "               $ CDFINQUIRE/DISPLAY=ih/OUTPUT=GISS_VEGX GISS_VEG",
  86. "               $ CDFINQUIRE/ID",
  87. #endif
  88. #if defined(unix)
  89. "Example(s):    % cdfinquire giss_veg",
  90. "               % cdfinquire -display ig+v ~/giss_veg",
  91. "               % cdfinquire -output giss_vegx giss_veg",
  92. "               % cdfinquire -display ih -output ../giss_vegx ~user/giss_veg",
  93. "               % cdfinquire -id",
  94. #endif
  95. #if defined(__MSDOS__)
  96. "Example(s):    > cdfinquire giss_veg",
  97. "               > cdfinquire -display ig+v ..\\giss_veg",
  98. "               > cdfinquire -output gissvegx giss_veg",
  99. "               > cdfinquire -display ih -output gissvegx a:\\giss_veg",
  100. "               > cdfinquire -id",
  101. #endif
  102. NULL };
  103.  
  104. /******************************************************************************
  105. * Global variables.
  106. ******************************************************************************/
  107.  
  108. CDFid id;        /* CDF identifier. */
  109. Boolean infoON;        /* Display INFO block? */
  110. Boolean headerON;    /* Display HEADER block? */
  111. Boolean VAdefON;    /* Display variable scope attribute definitions? */
  112. Boolean GAdefON;    /* Display global scope attribute definitions? */
  113. Boolean GAentryON;    /* Display global scope attribute entries? */
  114. Boolean VdefON;        /* Display variable definitions? */
  115. Boolean VAentryON;    /* Display variable scope attribute entries? */
  116. FILE *OUTfp;        /* Output file pointer. */
  117.  
  118. char CDFpath[MAX_PATH_LEN+1];    /* Pathname of CDF to inquire. */
  119.  
  120. static Boolean mLog = TRUE;    /* Message logging enabled? */
  121.  
  122. /******************************************************************************
  123. * Main.
  124. ******************************************************************************/
  125.  
  126. #if defined(vms)
  127. main (argc, argv)
  128. #else
  129. void main (argc, argv)
  130. #endif
  131. int argc;
  132. char *argv[];
  133. {
  134. CDFstatus status;
  135. char oSpec[MAX_PATH_LEN+1];
  136. char oDir[MAX_DIR_LEN+1];
  137. char oName[MAX_NAME_LEN+1];
  138. char CDFpathX[MAX_PATH_LEN+1];
  139. char *mask;
  140.  
  141. QOP *qop;
  142. static char *validQuals[] = { "display", "output", "id", NULL };
  143. static int optRequired[] = { TRUE, TRUE, FALSE, 0 };
  144.  
  145. /******************************************************************************
  146. * Process command line qualifiers/options/parameters.
  147. ******************************************************************************/
  148.  
  149. switch (argc) {
  150.   case 1:
  151.     PageInst (instructions);
  152.     Exit;
  153.   default:
  154.     qop = Qop (argc, argv, validQuals, optRequired);
  155.     if (qop == NULL) ExitBAD;
  156.  
  157.     /*************************************************************************
  158.     * Check for /ID,-id qualifier first (exit if specified).
  159.     *************************************************************************/
  160.  
  161.     if (qop->qualEntered[2]) {
  162.       DisplayVerRelInc ();
  163.       Exit;
  164.     }
  165.  
  166.     /*************************************************************************
  167.     * Get CDF path.
  168.     *************************************************************************/
  169.  
  170.     if (qop->Nparms < 1) {
  171.       printf ("Missing parameter.\n");
  172.       ExitBAD;
  173.     }
  174.     else {
  175.       strcpy (CDFpath, qop->parms[0]);
  176.     }
  177.  
  178.     /*************************************************************************
  179.     * Check for /DISPLAY,-display qualifier.
  180.     *************************************************************************/
  181.  
  182.     if (qop->qualEntered[0]) {
  183.       mask = qop->qualOpt[0];
  184.  
  185.       if (strchr(mask,'i') != NULL || strchr(mask,'I') != NULL)
  186.     infoON = TRUE;
  187.       else
  188.     infoON = FALSE;
  189.  
  190.       if (strchr(mask,'h') != NULL || strchr(mask,'H') != NULL)
  191.     headerON = TRUE;
  192.       else
  193.     headerON = FALSE;
  194.  
  195.       if (strchr(mask,'a') != NULL || strchr(mask,'A') != NULL)
  196.     VAdefON = TRUE;
  197.       else
  198.     VAdefON = FALSE;
  199.  
  200.       if (strstr(mask,"g+") != NULL || strstr(mask,"G+") != NULL) {
  201.     GAdefON = TRUE;
  202.     GAentryON = TRUE;
  203.       }
  204.       else {
  205.     if (strchr(mask,'g') != NULL || strchr(mask,'G') != NULL) {
  206.       GAdefON = TRUE;
  207.       GAentryON = FALSE;
  208.         }
  209.       }
  210.  
  211.       if (strstr(mask,"v+") != NULL || strstr(mask,"V+") != NULL) {
  212.     VdefON = TRUE;
  213.     VAentryON = TRUE;
  214.       }
  215.       else {
  216.     if (strchr(mask,'v') != NULL || strchr(mask,'V') != NULL) {
  217.       VdefON = TRUE;
  218.       VAentryON = FALSE;
  219.         }
  220.       }
  221.     }
  222.     else {                /* Default is ihg+v+ */
  223.       infoON = TRUE;
  224.       headerON = TRUE;
  225.       VAdefON = TRUE;
  226.       GAdefON = TRUE;
  227.       GAentryON = TRUE;
  228.       VdefON = TRUE;
  229.       VAentryON = TRUE;
  230.     }
  231.  
  232.     /*************************************************************************
  233.     * Check for /OUTPUT,-output qualifier.
  234.     *************************************************************************/
  235.  
  236.     if (qop->qualEntered[1]) {
  237.       strcpy (oSpec, qop->qualOpt[1]);
  238.       ParsePath (oSpec, oDir, oName);
  239.       if (strchr(oName,'.') == NULL) strcat (oSpec, ".inq");
  240.       OUTfp = fopen (oSpec, "w");
  241.       if (OUTfp == NULL) {
  242.         printf ("Unable to open output file (%s).\n", oSpec);
  243.         ExitBAD;
  244.       }
  245.     }
  246.     else
  247.       OUTfp = stdout;
  248.  
  249.     /*************************************************************************/
  250.  
  251.   break;
  252. }
  253.  
  254. /******************************************************************************
  255. * Open CDF.
  256. ******************************************************************************/
  257.  
  258. ExpandPath (CDFpath, CDFpathX);
  259. status = CDFlib (OPEN_, CDF_, CDFpathX, &id,
  260.          NULL_);
  261. StatusHandler (status);
  262.  
  263. /******************************************************************************
  264. * Output information block.
  265. ******************************************************************************/
  266.  
  267. if (infoON) OutInfoBlock ();
  268.  
  269. /******************************************************************************
  270. * Output header block.
  271. ******************************************************************************/
  272.  
  273. if (headerON) OutHeaderBlock ();
  274.  
  275. /******************************************************************************
  276. * Output global scope attributes.
  277. ******************************************************************************/
  278.  
  279. if (GAdefON) OutGlobalAttrs ();
  280.  
  281. /******************************************************************************
  282. * Output variable scope attributes.
  283. ******************************************************************************/
  284.  
  285. if (VAdefON) OutVarAttrs ();
  286.  
  287. /******************************************************************************
  288. * Output variables/variable scope attributes.
  289. ******************************************************************************/
  290.  
  291. if (VdefON) OutVariables ();
  292.  
  293. /******************************************************************************
  294. * Close CDF, output file (if specified), and exit.
  295. ******************************************************************************/
  296.  
  297. status = CDFlib (SELECT_, CDF_, id,
  298.          CLOSE_, CDF_,
  299.          NULL_);
  300. StatusHandler (status);
  301.  
  302. if (OUTfp != stdout) fclose (OUTfp);
  303.  
  304. Exit;
  305. }
  306.  
  307.  
  308.  
  309.  
  310.  
  311. /******************************************************************************
  312. * Output information block.
  313. ******************************************************************************/
  314.  
  315. void OutInfoBlock () {
  316. CDFstatus status;
  317. char copyright[CDF_COPYRIGHT_LEN+1];
  318. long version, release, increment;
  319.  
  320. fprintf (OUTfp, "\nINFORMATION BLOCK\n");
  321. fprintf (OUTfp, "-----------------\n");
  322.  
  323. status = CDFlib (SELECT_, CDF_, id,
  324.          GET_, CDF_COPYRIGHT_, copyright,
  325.                CDF_VERSION_, &version,
  326.                CDF_RELEASE_, &release,
  327.                CDF_INCREMENT_, &increment,
  328.          NULL_);
  329. StatusHandler (status);
  330.  
  331. fprintf (OUTfp, "%s\n", copyright);
  332.  
  333. fprintf (OUTfp, "Created by CDF library version: %ld.%ld.%ld\n\n",
  334.      version, release, increment);
  335.  
  336. return;
  337. }
  338.  
  339.  
  340.  
  341.  
  342.  
  343. /******************************************************************************
  344. * Output header block.
  345. ******************************************************************************/
  346.  
  347. void OutHeaderBlock () {
  348. CDFstatus status;
  349. char CDFdir[MAX_DIR_LEN+1];
  350. char CDFname[MAX_DIR_LEN+1];
  351. long encoding, format, majority;
  352. long numVars, numAttrs;
  353. long VAcount = 0, GAcount = 0;
  354. long numDims, dimSizes[CDF_MAX_DIMS];
  355. long maxRec;
  356. long scope, attrN;
  357. int dimN;
  358.  
  359. fprintf (OUTfp, "\nHEADER BLOCK\n");
  360. fprintf (OUTfp, "------------\n\n");
  361.  
  362. status = CDFlib (SELECT_, CDF_, id,
  363.          GET_, CDF_FORMAT_, &format,
  364.                CDF_MAJORITY_, &majority,
  365.                CDF_ENCODING_, &encoding,
  366.                CDF_NUMDIMS_, &numDims,
  367.                CDF_DIMSIZES_, dimSizes,
  368.                CDF_NUMVARS_, &numVars,
  369.                CDF_NUMATTRS_, &numAttrs,
  370.                CDF_MAXREC_, &maxRec,
  371.          NULL_);
  372. StatusHandler (status);
  373.  
  374. for (attrN = 0; attrN < numAttrs; attrN++) {
  375.    status = CDFlib (SELECT_, CDF_, id,
  376.                  ATTR_, attrN,
  377.             GET_, ATTR_SCOPE_, &scope,
  378.             NULL_);
  379.    StatusHandler (status);
  380.  
  381.    switch (scope) {
  382.      case GLOBAL_SCOPE:
  383.      case GLOBAL_SCOPE_ASSUMED:
  384.        GAcount++;
  385.        break;
  386.      case VARIABLE_SCOPE:
  387.      case VARIABLE_SCOPE_ASSUMED:
  388.        VAcount++;
  389.        break;
  390.    }
  391. }
  392.  
  393. ParsePath (CDFpath, CDFdir, CDFname);
  394. fprintf (OUTfp, "  CDF name..... %s\n", CDFname);
  395.  
  396. fprintf (OUTfp, "  Encoding..... %s\n", EncodingToken(encoding));
  397. fprintf (OUTfp, "  Majority..... %s\n", MajorityToken(majority));
  398. fprintf (OUTfp, "  Format....... %s\n", FormatToken(format));
  399.  
  400. fprintf (OUTfp, "  Records...... %ld\n", maxRec + 1);
  401.  
  402. fprintf (OUTfp, "  Attributes... %ld", numAttrs);
  403. if (GAcount > 0)
  404.   if (VAcount > 0)
  405.     fprintf (OUTfp, " (%ld global scope, %ld variable scope)",
  406.          GAcount, VAcount);
  407.   else
  408.     fprintf (OUTfp, " (all global scope)");
  409. else
  410.   if (VAcount > 0) fprintf (OUTfp, " (all variable scope)");
  411. fprintf (OUTfp, "\n");
  412.  
  413. fprintf (OUTfp, "  Variables.... %ld\n", numVars);
  414.  
  415. fprintf (OUTfp, "  Dimensions... %ld", numDims);
  416. if (numDims > 0) {
  417.   fprintf (OUTfp, ", sizes:");
  418.   for (dimN = 0; dimN < numDims; dimN++)
  419.      fprintf (OUTfp, " %ld", dimSizes[dimN]);
  420. }
  421. fprintf (OUTfp, "\n\n");
  422.  
  423. return;
  424. }
  425.  
  426.  
  427.  
  428.  
  429.  
  430. /******************************************************************************
  431. * Output global scope attributes.
  432. ******************************************************************************/
  433.  
  434. void OutGlobalAttrs () {
  435. CDFstatus status;
  436. long numAttrs;
  437. long entryN, attrN;
  438. long attrScope;
  439. long maxEntry, numEntries;
  440. long dataType, numElems;
  441. char attrName[CDF_ATTR_NAME_LEN+1];
  442. char delim;
  443. void *buffer;
  444. int ccc;                    /* Current Cursor Column. */
  445.  
  446. fprintf (OUTfp, "\nGLOBAL SCOPE ATTRIBUTES\n");
  447. fprintf (OUTfp, "-----------------------\n\n");
  448.  
  449. status = CDFlib (SELECT_, CDF_, id,
  450.          GET_, CDF_NUMATTRS_, &numAttrs,
  451.          NULL_);
  452. StatusHandler (status);
  453.  
  454. for (attrN = 0; attrN < numAttrs; attrN++) {
  455.    status = CDFlib (SELECT_, CDF_, id,
  456.                  ATTR_, attrN,
  457.             GET_, ATTR_NAME_, attrName,
  458.               ATTR_SCOPE_, &attrScope,
  459.               ATTR_MAXENTRY_, &maxEntry,
  460.               ATTR_NUMENTRIES_, &numEntries,
  461.             NULL_);
  462.    StatusHandler (status);
  463.  
  464.    if (attrScope == GLOBAL_SCOPE || attrScope == GLOBAL_SCOPE_ASSUMED) {
  465.      /*************************************************************************
  466.      * Global scope attribute.
  467.      *************************************************************************/
  468.  
  469.      delim = PickDelim (attrName);
  470.      fprintf (OUTfp, "%3ld.  Name...... %c%s%c\n",
  471.           attrN + 1, delim, attrName, delim);
  472.      fprintf (OUTfp, "      Entries... %ld\n\n", numEntries);
  473.  
  474.      if (GAentryON && numEntries > 0) {
  475.        for (entryN = 0; entryN <= maxEntry; entryN++) {
  476.       status = CDFlib (SELECT_, CDF_, id,
  477.                     ENTRY_, entryN,
  478.                    GET_, ENTRY_DATATYPE_, &dataType,
  479.                  ENTRY_NUMELEMS_, &numElems,
  480.                NULL_);
  481.       if (status != NO_SUCH_ENTRY) {
  482.         StatusHandler (status);
  483.  
  484.         fprintf (OUTfp, "         Number...... %ld\n", entryN + 1);
  485.         fprintf (OUTfp, "         Data type... CDF%s (%ld elements)\n",
  486.              DataTypeToken(dataType), numElems);
  487.  
  488.         MALLOC (buffer, ElemSize(dataType) * numElems);
  489.         status = CDFlib (SELECT_, CDF_, id,
  490.                  GET_, ENTRY_DATA_, buffer,
  491.                  NULL_);
  492.         StatusHandler (status);
  493.  
  494.         if (STRINGdataType(dataType))
  495.           ccc = fprintf (OUTfp, "         Value....... ");
  496.         else
  497.           ccc = fprintf (OUTfp, "         %s...... ",
  498.                  (numElems > 1 ? "Values" : "Value."));
  499.         WriteEntryValue (OUTfp, dataType, numElems, buffer, ccc,
  500.                  MAX_COL_TO_USE);
  501.         fprintf (OUTfp, "\n\n");
  502.  
  503.         free (buffer);
  504.       }
  505.        }
  506.      }
  507.    }
  508. }
  509.  
  510. return;
  511. }
  512.  
  513.  
  514.  
  515.  
  516.  
  517. /******************************************************************************
  518. * Output variable scope attributes.
  519. ******************************************************************************/
  520.  
  521. void OutVarAttrs () {
  522. CDFstatus status;
  523. long numAttrs;
  524. long attrN;
  525. long attrScope;
  526. long numEntries;
  527. char attrName[CDF_ATTR_NAME_LEN+1];
  528. char delim;
  529.  
  530. fprintf (OUTfp, "\nVARIABLE SCOPE ATTRIBUTES\n");
  531. fprintf (OUTfp, "-------------------------\n\n");
  532.  
  533. status = CDFlib (SELECT_, CDF_, id,
  534.          GET_, CDF_NUMATTRS_, &numAttrs,
  535.          NULL_);
  536. StatusHandler (status);
  537.  
  538. for (attrN = 0; attrN < numAttrs; attrN++) {
  539.    status = CDFlib (SELECT_, CDF_, id,
  540.                  ATTR_, attrN,
  541.             GET_, ATTR_NAME_, attrName,
  542.               ATTR_SCOPE_, &attrScope,
  543.               ATTR_NUMENTRIES_, &numEntries,
  544.             NULL_);
  545.    StatusHandler (status);
  546.  
  547.    if (attrScope == VARIABLE_SCOPE || attrScope == VARIABLE_SCOPE_ASSUMED) {
  548.      /*************************************************************************
  549.      * Variable scope attribute.
  550.      *************************************************************************/
  551.  
  552.      delim = PickDelim (attrName);
  553.      fprintf (OUTfp, "%3ld.  Name...... %c%s%c\n",
  554.           attrN + 1, delim, attrName, delim);
  555.      fprintf (OUTfp, "      Entries... %ld\n\n", numEntries);
  556.    }
  557. }
  558.  
  559. return;
  560. }
  561.  
  562.  
  563.  
  564.  
  565.  
  566. /******************************************************************************
  567. * Output variables/variable scope attributes.
  568. ******************************************************************************/
  569.  
  570. void OutVariables () {
  571. CDFstatus status;
  572. long varN, attrN;
  573. long numVars, numAttrs;
  574. long dataType, numElems;
  575. char varName[CDF_VAR_NAME_LEN+1];
  576. char attrName[CDF_ATTR_NAME_LEN+1];
  577. long numDims;
  578. long recVary, dimVarys[CDF_MAX_DIMS];
  579. char delim;
  580. int dimN;
  581. long attrScope;
  582. void *buffer;
  583. int ccc;                    /* Current Cursor Column. */
  584.  
  585. fprintf (OUTfp, "\nVARIABLES\n");
  586. fprintf (OUTfp, "---------\n\n");
  587.  
  588. status = CDFlib (SELECT_, CDF_, id,
  589.          GET_, CDF_NUMVARS_, &numVars,
  590.                CDF_NUMATTRS_, &numAttrs,
  591.                CDF_NUMDIMS_, &numDims,
  592.          NULL_);
  593. StatusHandler (status);
  594.  
  595. for (varN = 0; varN < numVars; varN++) {
  596.    status = CDFlib (SELECT_, CDF_, id,
  597.                  VAR_, varN,
  598.             GET_, VAR_NAME_, varName,
  599.               VAR_DATATYPE_, &dataType,
  600.               VAR_NUMELEMS_, &numElems,
  601.               VAR_RECVARY_, &recVary,
  602.               VAR_DIMVARYS_, dimVarys,
  603.             NULL_);
  604.    StatusHandler (status);
  605.  
  606.    delim = PickDelim (varName);
  607.    fprintf (OUTfp, "%3ld.  Name........ %c%s%c\n",
  608.         varN + 1, delim, varName, delim);
  609.    fprintf (OUTfp, "      Data type... CDF%s (%ld element%s)\n",
  610.         DataTypeToken(dataType), numElems, (numElems == 1 ? "" : "s"));
  611.    fprintf (OUTfp, "      Variances... %s/", TFvarianceToken(recVary));
  612.    if (numDims > 0) {
  613.      for (dimN = 0; dimN < numDims; dimN++)
  614.     fprintf (OUTfp, "%s", TFvarianceToken(dimVarys[dimN]));
  615.    }
  616.    fprintf (OUTfp, "\n\n");
  617.  
  618.    if (VAentryON) {
  619.      for (attrN = 0; attrN < numAttrs; attrN++) {
  620.     status = CDFlib (SELECT_, CDF_, id,
  621.                   ATTR_, attrN,
  622.              GET_, ATTR_NAME_, attrName,
  623.                    ATTR_SCOPE_, &attrScope,
  624.              NULL_);
  625.     StatusHandler (status);
  626.  
  627.     if (attrScope == VARIABLE_SCOPE ||
  628.         attrScope == VARIABLE_SCOPE_ASSUMED) {
  629.       /********************************************************************
  630.       * Variable scope attribute.
  631.       ********************************************************************/
  632.  
  633.       status = CDFlib (SELECT_, CDF_, id,
  634.                     ENTRY_, varN,
  635.                GET_, ENTRY_DATATYPE_, &dataType,
  636.                  ENTRY_NUMELEMS_, &numElems,
  637.                NULL_);
  638.       if (status != NO_SUCH_ENTRY) {
  639.         StatusHandler (status);
  640.  
  641.         fprintf (OUTfp, "         Attribute name... %c%s%c\n",
  642.              delim, attrName, delim);
  643.         fprintf (OUTfp,
  644.              "         Data type........ CDF%s (%ld element%s)\n",
  645.              DataTypeToken(dataType), numElems,
  646.              (numElems == 1 ? "" : "s"));
  647.  
  648.         MALLOC (buffer, numElems * ElemSize(dataType));
  649.         status = CDFlib (SELECT_, CDF_, id,
  650.                  GET_, ENTRY_DATA_, buffer,
  651.                  NULL_);
  652.         StatusHandler (status);
  653.  
  654.         if (STRINGdataType(dataType))
  655.           ccc = fprintf (OUTfp, "         Value............ ");
  656.         else
  657.           ccc = fprintf (OUTfp, "         %s........... ",
  658.                  (numElems > 1 ? "Values" : "Value."));
  659.         WriteEntryValue (OUTfp, dataType, numElems, buffer, ccc,
  660.                  MAX_COL_TO_USE);
  661.         fprintf (OUTfp, "\n\n");
  662.  
  663.         free (buffer);
  664.       }
  665.     }
  666.      }
  667.    }
  668. }
  669.  
  670. return;
  671. }
  672.  
  673.  
  674.  
  675.  
  676.  
  677. /******************************************************************************
  678. * Display CDF library version/release/increment/sub-increment.
  679. ******************************************************************************/
  680.  
  681. void DisplayVerRelInc () {
  682. CDFstatus status;
  683. long version, release, increment;
  684. char subincrement;
  685.  
  686. status = CDFlib (GET_, LIB_VERSION_, &version,
  687.                LIB_RELEASE_, &release,
  688.                LIB_INCREMENT_, &increment,
  689.                LIB_subINCREMENT_, &subincrement,
  690.          NULL_);
  691. StatusHandler (status);
  692.  
  693. printf ("CDF distribution V%ld.%ld.%ld%c\n",
  694.     version, release, increment, subincrement);
  695.  
  696. return;
  697. }
  698.  
  699.  
  700.  
  701.  
  702.  
  703. /******************************************************************************
  704. * StatusHandler.
  705. ******************************************************************************/
  706.  
  707. void StatusHandler (status)
  708. CDFstatus status;
  709. {
  710. char text[CDF_STATUSTEXT_LEN + 1];
  711.  
  712. if (status == CDF_OK) return;        /* Do nothing. */
  713.  
  714. CDFlib (SELECT_, CDF_STATUS_, status,
  715.     GET_, STATUS_TEXT_, text,
  716.     NULL_);
  717.  
  718. if (status < CDF_WARN) {
  719.   printf ("ERROR> %s\n", text);
  720.   ExitBAD;
  721. }
  722. else
  723.   if (mLog)
  724.     if (status < CDF_OK)
  725.       printf ("WARNING> %s\n", text);
  726.     else
  727.       printf ("INFO> %s\n", text);
  728.  
  729. return;
  730. }
  731.